<?php

namespace App\Http\Controllers\Admin;

use App\Models\ServerType;
use Illuminate\Http\Request;
use App\Models\Admin;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;

class ServerTypeController extends BaseDefaultController
{

    public function setModel()
    {
        $this->model = new ServerType();
    }

    public function setSearchParam($arr)
    {
        unset($arr['group_type']);
        return parent::setSearchParam($arr);
    }

    public function server()
    {
        return $this->display()->with([
            'data' => config('server_type')
        ]);
    }


    /**
     * 创建/更新共享数据
     * @param string $id
     * @return array
     */
    public function createEditData($id='')
    {
        $data = config('server_type');
        return ['area' => $data['area']];
    }


    /**
     * 表单验证规则
     * @param string $id
     * @return array
     */
    public function checkRule($id = '')
    {
        return [
            'server_name' => 'required',
            'server_type' => 'required',
            'price' => 'required',
            'area' => 'required',
        ];

    }


    public function apiJsonItemExtend($item)
    {
       $item->roles_arr=$item->roles->pluck('cn_name')->toArray();
       return $item;
    }


}
